package edu.suse.controller;

import edu.suse.common.base.RespResult;
import edu.suse.entity.SysRole;
import edu.suse.service.SysRoleService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

@RestController
@RequestMapping("/sys_role")
@Api(value = "角色数据test",tags = "角色操作接口API")
public class SysRoleController {

    @Autowired
    private SysRoleService sysRoleService;

    //   查询指定状态下的所有角色
    @GetMapping(value = "/findSysRoleAllStatus")
    public RespResult findSysRoleAllStatus(Long status){
        return sysRoleService.findSysRoleAllStatus(status);
    }

    @GetMapping(value = "/findSysRoleByName")
    public RespResult findSysRoleByName(String name){
        return sysRoleService.findSysRoleByName(name);
    }

    @GetMapping(value = "/findSysRoleByTitle")
    public RespResult findSysRoleByTitle(String title){
        return sysRoleService.findSysRoleByTitle(title);
    }

    //    增加角色
    @GetMapping(value = "/addSysRole")
    public RespResult addSysRole(String title, String name, String remark){
        return sysRoleService.addSysRole(title, name, remark);
    }

    //    删除角色
    @GetMapping(value = "/deleteSysRole")
    public RespResult deleteSysRole(String name){
        return sysRoleService.deleteSysRole(name);
    }

    //    更新角色信息
    @GetMapping(value = "/updateSysRole")
    public RespResult updateSysRole(SysRole sysRole){
        Long roleId = sysRole.getId();
        String title = sysRole.getTitle();
        String name = sysRole.getName();
        String remark = sysRole.getRemark();
        return sysRoleService.updateSysRole(roleId, title, name, remark);
    }

    // 启用/冻结/删除多个角色
    @GetMapping(value = "/updateSysRoleStatus")
    public RespResult updateSysRoleStatus(ArrayList<Long> roleIds, Long status){
        return sysRoleService.updateSysRoleStatus(roleIds, status);
    }
}
